<template>
  <div class="Mytest">
    <p class="p-3">你参加的考试都在这里哦！</p>
    <div class="main-contain p-3">
        <router-link tag="div" :to="{path: `/myquestions/${item._id}`}"
          class="main-item mb-3" v-for="(item,i) in model" :key="i" >
          <div class="main-list p-2 ">
         <div class="content p-2 d-flex jc-between">
          <div class="title fs-16 mb-3">{{item.title}}</div>   
           <div class="bywho">— {{item.bywho}}</div>
         </div>
          </div>
        </router-link>
      </div>
  </div>
</template>

<script>
export default {
  filters: {
    filtersText(val) {
      // 要判断一下,如果是空就返回空字符串,不然会报错
      if (val != null && val != "") {
        var reg = /[\u4e00-\u9fa5]/g;
        var names = val.match(reg);
        val = names.join("");
        return val.substr(0, 10); //获取富文本文字内容的前50个字符
      } else return "";
    },
  },
  data() {
    return {
      model: {

      },
      num: '',
      username: ''
    }
  },
methods: {
  async fetch() {
    this.username = window.sessionStorage.getItem('username')
    const res = await this.$http.get(`/mytest/${this.username}`)
    this.model = res.data
 
  } 
},
created() {
  this.fetch()
},
}
</script>

<style lang="scss">
.Mytest {
  height: 100vh;
  background-color: #edf1f2;
}
  .main-item {
    width: 100%;
    height: 44px;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 0 5px rgba($color: #000000, $alpha: .3);
    img {
      width: 82px;
      height: 82px;
    }

    .bywho {
      float: right;
    }
  }
</style>